package com.jpemartin.jgt;
import java.awt.Rectangle;

/** move horizontally following a cosine wave.
 * @see MoveVerticalWave
 * 
 * @author jpmartin
 */
public class MoveHorizontalWave implements MoveControl {

   // angular velocity
   protected int _da;
   // amplitude
   protected int _dx;
   
   // previous X delta
   protected int _odx = 0;
   protected int _angle = 0;
   
   public MoveHorizontalWave(int amplitude, int angularVelocity) {
      _da = angularVelocity;
      _dx = amplitude;
      _angle = 0;
   }
   
   public void move(Rectangle moved) {
      _angle += _da;
      int change = (int)(Math.cos((double)(_angle)/180.0*Math.PI)*_dx);
      moved.x = moved.x - _odx + change;
      _odx = change;
   }

}
